home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / Pasc / TN.PASC.015 < prev    next >
Encoding:
Text File  |  1988-12-15  |  7.3 KB  |  221 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Pascal
  8. #15:    Apple II Pascal SHORTGRAPHICS Module
  9.  
  10. Revised by:    Cheryl Ewy & Dan Strnad                          November 1988
  11. Written by:    Cheryl Ewy                                       December 1983
  12.  
  13. This Technical Note describes the Apple II Pascal SHORTGRAPHICS routine, which 
  14. is available as part of the 48K Run-Time System.
  15. _____________________________________________________________________________
  16.  
  17.  
  18. Introduction
  19.  
  20. Many applications, especially those designed to use the 48K Run-Time System, 
  21. run out of memory quickly if they use the TURTLEGRAPHICS unit provided with 
  22. the standard SYSTEM.LIBRARY.
  23.  
  24. This document describes a library unit called SHORTGRAPHICS which removes the 
  25. relative polar coordinate features of TURTLEGRAPHICS to save memory.
  26.  
  27.  
  28. General Comments
  29.  
  30. If your application uses (or can be modified to use) only those TURTLEGRAPHICS 
  31. procedures which refer to absolute screen coordinates, you can use the 
  32. SHORTGRAPHICS unit.  The SHORTGRAPHICS unit has the same segment numbers 
  33. assigned to it, as does TURTLEGRAPHICS, thus you may not use both in the same 
  34. program.
  35.  
  36.  
  37. Deletions
  38.  
  39. The following routines are not available in the SHORTGRAPHICS unit:
  40.  
  41.     PROCEDURE TURN(ANGLE: INTEGER);
  42.     PROCEDURE TURNTO(ANGLE: INTEGER);
  43.     PROCEDURE MOVE(DIST: INTEGER);
  44.     FUNCTION  TURTLEANG: INTEGER;
  45.  
  46.  
  47. Additions
  48.  
  49. The following definitions have been added to the INTERFACE section of 
  50. SHORTGRAPHICS:
  51.  
  52.     TYPE 
  53.         FONT=PACKED ARRAY[0..127,0..7] OF 0..255; 
  54.     VAR
  55.         FONTPTR:^FONT; 
  56.  
  57. The variable FONTPTR is a pointer to the memory area used by the WCHAR and 
  58. WSTRING procedures to display text on the graphics screen.
  59.  
  60. Thus, if you have a character set named KATAKANA.FONT, you could load it into 
  61. memory and use it as follows:
  62.  
  63.     VAR 
  64.         SPECIALFONT:^FONT;        (* where the new font goes *)
  65.         SAVEFONT:^FONT;           (* to save pointer to standard font area *)
  66.  
  67.         PROCEDURE LOADFONT; 
  68.         VAR
  69.             F:FILE; 
  70.             NIO:INTEGER;
  71.         BEGIN
  72.             NEW(SPECIALFONT);
  73.             RESET(F,'KATAKANA.FONT');
  74.             NIO:=BLOCKREAD(F,SPECIALFONT^,2,0);
  75.             CLOSE(F)
  76.         END; 
  77.  
  78.         PROCEDURE USESPECIAL;
  79.         BEGIN
  80.             SAVEFONT:=FONTPTR;    (* save standard font pointer *)
  81.             FONTPTR:=SPECIALFONT; (* and point to special font *)
  82.         END; 
  83.  
  84.         PROCEDURE USENORMAL;
  85.         BEGIN 
  86.             FONTPTR:=SAVEFONT     (* restore pointer to normal font *)
  87.         END;
  88.  
  89.  
  90. Memory Considerations
  91.  
  92. When the system is booted, the heap pointer is normally below the start of 
  93. high-resolution page one.  The TURTLEGRAPHICS unit automatically sets the heap 
  94. pointer above high-resolution page one.  This protects the high-resolution 
  95. page from being overwritten by your program, but it also prevents you from 
  96. using the space between the original top of the heap and the start of high-
  97. resolution page one for your own variables.
  98.  
  99. SHORTGRAPHICS does not protect the high-resolution page, thus you may use this 
  100. extra space for yourself.  The following code will check to see if you have n 
  101. bytes available between the top of the heap and high-resolution page one.  If 
  102. the room is not available, the heap pointer will be jumped to the top of the 
  103. high-resolution page.
  104.  
  105.     PROCEDURE MAKEROOM(N:INTEGER);
  106.     CONST
  107.         BOTTOM=8192; 
  108.  
  109.         TOP=16384;
  110.     VAR 
  111.         CHEAT:RECORD CASE BOOLEAN 
  112.                 TRUE:(IPART:INTEGER); 
  113.                 FALSE:(PPART:^INTEGER);
  114.             END;
  115.     BEGIN
  116.         MARK(CHEAT.PPART);
  117.         IF (CHEAT.IPART+N)>=BOTTOM THEN BEGIN
  118.             CHEAT.IPART:=TOP; 
  119.             RELEASE(CHEAT.PPART)
  120.         END
  121.     END;
  122.  
  123. Thus, if you wanted to allocate a special font (which requires 1,024 bytes) 
  124. below the high-resolution page, you could use this code:
  125.  
  126.     MAKEROOM(1024);
  127.     NEW(SPECIALFONT); 
  128.  
  129. If there are at least 1,024 bytes beneath the high-resolution page, the new 
  130. font will be allocated there.  If there is not enough space there, the new 
  131. font will be allocated above the high-resolution page.
  132.  
  133. All of these heap allocations should be done as the very first actions of your 
  134. program.  When you finish allocating your variables, you should invoke the 
  135. following procedure to make sure the heap pointer is above high-resolution 
  136. page one (thus protecting it).
  137.  
  138.     PROCEDURE PROTECT;
  139.     CONST    
  140.         TOP=16384;
  141.     VAR
  142.         CHEAT:RECORD CASE BOOLEAN OF
  143.                     TRUE:(IPART:INTEGER);
  144.                     FALSE:(PPART:^INTEGER);
  145.                 END;
  146.     BEGIN
  147.         MARK(CHEAT.PPART);
  148.         IF CHEAT.IPART<TOP THEN BEGIN
  149.             CHEAT.IPART:=TOP;
  150.             RELEASE(CHEAT.PPART);
  151.         END;
  152.     END; 
  153.  
  154. Warning:    Every program written using SHORTGRAPHICS is unprotected 
  155. from a heap which grows large enough to go into the high-
  156. resolution page one area.  Therefore, every program using 
  157. SHORTGRAPHICS should protect page one by using PROCEDURE 
  158. PROTECT.  You should protect page one even if the program 
  159. does not use the space below it.
  160.  
  161.  
  162. Code Length
  163.  
  164. When you look at TURTLEGRAPHICS with the LIBRARY program, the code segment has 
  165. a length of 5,230 bytes and the data segment a length of 386 bytes.  
  166. SHORTGRAPHICS has a code segment 3,140 bytes in length and a data segment of 
  167. 18 bytes.  Thus, in a test of a null program, you have 2,458 bytes more space 
  168. available.
  169.  
  170.  
  171. Files on the Disk
  172.  
  173. The following files are on the SHORT GRAPHICS disk:
  174.  
  175. SHORT.CODE              Contains the SHORTGRAPHICS code.  You can use it as a 
  176.                         library or use the library program to add it to 
  177.                         SYSTEM.LIBRARY in place of TURTLEGRAPHICS.
  178. KATAKANA.FONT           A sample font used to demonstrate the use of alternate 
  179.                         fonts.
  180. SYSTEM.CHARSET          The letters in this character set are not as wide as 
  181.                         those found in the SYSTEM.CHARSET supplied with the 
  182.                         Development System and the Run-Time Systems.
  183. TEST.TEXT, TEST.CODE    A sample program showing some of the concepts 
  184.                         discussed in this Technical Note.
  185.  
  186.  
  187. Interface Listing of the SHORTGRAPHICS Unit:
  188.  
  189. The following is the interface section of the SHORTGRAPHICS unit: 
  190.  
  191. UNIT SHORTGRAPHICS; INTRINSIC CODE 20  DATA 21; 
  192.  
  193.     INTERFACE
  194.         TYPE
  195.             
  196.             SCREENCOLOR=(none,white,black,reverse,radar,black1,green,violet,white1,
  197.                          black2,orange,blue,white2);
  198.  
  199.             FONT=PACKED ARRAY[0..127,0..7] OF 0..255;
  200.  
  201.         VAR
  202.             FONTPTR:^FONT;
  203.  
  204.         PROCEDURE INITTURTLE;
  205.         PROCEDURE MOVETO(X,Y: INTEGER);
  206.         PROCEDURE PENCOLOR(PENMODE: SCREENCOLOR);
  207.         PROCEDURE TEXTMODE;
  208.         PROCEDURE GRAFMODE;
  209.         PROCEDURE FILLSCREEN(FILLCOLOR: SCREENCOLOR);
  210.         PROCEDURE VIEWPORT(LEFT,RIGHT,BOTTOM,TOP: INTEGER);
  211.         FUNCTION  TURTLEX: INTEGER;
  212.         FUNCTION  TURTLEY: INTEGER;
  213.         FUNCTION  SCREENBIT(X,Y: INTEGER): BOOLEAN;
  214.         PROCEDURE DRAWBLOCK(VAR SOURCE; ROWSIZE,XSKIP,YSKIP,WIDTH,
  215.                             HEIGHT,XSCREEN,YSCREEN,MODE:
  216.                             INTEGER);
  217.         PROCEDURE WCHAR(CH: CHAR);
  218.         PROCEDURE WSTRING(S: STRING);
  219.         PROCEDURE CHARTYPE(MODE: INTEGER); 
  220.  
  221.